<div class="row">
	<div class="col-md-12">
		<form id="fileEditForm" class="form-horizontal" action="${request.contextPath}/system/config/file/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${sysFile.id}">
			<div class="box-body">
				<div class="form-group">
					<label id="fileTitleLabel" for="fileTitle" class="col-sm-1 control-label">标题</label>
					<div class="col-sm-11">
						<input id="fileTitle"  type="text" class="form-control" name="title" value="${sysFile.title}" placeholder="输入文件标题...">
					</div>
				</div>
				<div class="form-group">
					<label id="sysFileTypeLabel" for="sysFileType" class="col-sm-1  control-label">类型</label>
					<div class="col-sm-3">
						<select class="form-control" id="sysFileType" name="type"  value="${sysFile.type}"  style="width: 100%;"  placeholder="选择文件类型...">
						</select>
					</div>
					<label id="fileSeqLabel" for="fileSeq" class="col-sm-1  control-label">排序号</label>
					<div class="col-sm-3">
						<input type="text" class="form-control" name="seq" id="fileSeq" type="number" value="${sysFile.seq}" placeholder="输入排序号...">
					</div>
					<label id="sysFileStatusLabel" for="sysFileStatus" class="col-sm-1  control-label">状态</label>
					<div class="col-sm-3">
						<select class="form-control" id="sysFileStatus"  name="status" value="${sysFile.status}" style="width: 100%;" placeholder="选择状态...">
						</select>
					</div>
				</div>
				<div class="form-group">
					<label id="fileDirLabel" for="fileDir" class="col-sm-1 control-label">原文件</label>
					<div class="col-sm-11">
						<input id="fileDir" name="fileDir"  class="form-control"  value="${sysFile.url}" type="text" readonly="readonly" placeholder="输入路径..."/>
					</div>
				</div>
				<div class="form-group">
					<label id="fileLabel" for="file" class="col-sm-1 control-label">上传</label>
					<div class="col-sm-11">
						<input id="file" type="file" name="file"  />
					</div>
				</div>
				<div class="form-group">
					<label id="fileDescriptionLabel" class="col-sm-1 control-label" >描述</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="description" id="fileDescription"  value="${sysFile.description}"  placeholder="输入描述...">
					</div>
				</div>
				<div class="form-group">
					<label id="fileRemarkLabel" class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="remark" id="fileRemark" value="${sysFile.remark}" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" >
					<span class="error-icon"></span>
					<span id="error-msg" class="error-msg" ></span>
				</div>
             </div>
			<div class="box-footer">
				<div class="pull-right">
               		<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 更新</button>
               		<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
          	</div>
		</form>
	</div>
</div>

<script src="${request.contextPath}/static/oms/default/plugins/jQuery/jquery.form.js"></script>

<script type="text/javascript">
function ajaxSubmit(form) {
    var $form = $(form);
    $form.ajaxSubmit({
        //定义返回JSON数据，还包括xml和script格式
        dataType:'json',
        url:form.action,
        success: function(result) {
            //提交成功后调用
            if (result.success) {
                $("#lgModal").modal('hide');
                alertMsg(result.message,"success");
                fileReload();
            } else {
                $form.find(".error-msg").show();
                $form.find(".error-msg").html(result.message);
            }
        }
    });
}

$(function() {

    $("#sysFileType").select2({
        data: FileTypeStore
    }).val('${sysFile.type}').trigger("change");;

	$("#sysFileStatus").select2({
        data: StatusStore
    }).val('${sysFile.status}').trigger("change");

	$fileEditForm = $("#fileEditForm");
	$fileEditForm.validate({
		rules: {
            seq: {
                required: true
            }
		},
		messages: {
            seq: {
                required: "排序号不能为空！"
            }
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:".error-msg",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$fileEditForm.find(".error-msg").html(errorList[0].message);
			}else{
				$fileEditForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>